From: kfraser@dhcp93.uk.xensource.com Date: Fri, 30 Jun 2006 13:30:43 +0000 (+0100) Subject: [BLK] back: Only remove sysfs attributes if they were previously X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~15912^2~12 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=4509ffb83c9a82528bb2988868210af8c73eeebe;p=xen.git [BLK] back: Only remove sysfs attributes if they were previously added. Also check for errors during attribute creation. Signed-off-by: Keir Fraser --- diff --git a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c index f796c2f2c8..59d93242b5 100644 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c @@ -109,7 +109,7 @@ VBD_SHOW(mode, "%s\n", be->mode); int xenvbd_sysfs_addif(struct xenbus_device *dev) { - int error = 0; + int error; error = device_create_file(&dev->dev, &dev_attr_physical_device); if (error) @@ -157,7 +157,8 @@ static int blkback_remove(struct xenbus_device *dev) be->blkif = NULL; } - xenvbd_sysfs_delif(dev); + if (be->major || be->minor) + xenvbd_sysfs_delif(dev); kfree(be); dev->dev.driver_data = NULL; @@ -272,13 +273,18 @@ static void backend_changed(struct xenbus_watch *watch, err = vbd_create(be->blkif, handle, major, minor, (NULL == strchr(be->mode, 'w'))); if (err) { - be->major = 0; - be->minor = 0; + be->major = be->minor = 0; xenbus_dev_fatal(dev, err, "creating vbd structure"); return; } - xenvbd_sysfs_addif(dev); + err = xenvbd_sysfs_addif(dev); + if (err) { + vbd_free(&be->blkif->vbd); + be->major = be->minor = 0; + xenbus_dev_fatal(dev, err, "creating sysfs entries"); + return; + } /* We're potentially connected now */ update_blkif_status(be->blkif);